package com.morehair.service.admin.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.morehair.bean.bo.admin.CreateGoodsBo;
import com.morehair.bean.bo.admin.GoodsBo;
import com.morehair.bean.bo.admin.UpdateGoodsBo;
import com.morehair.bean.pojo.*;
import com.morehair.bean.vo.admin.*;
import com.morehair.mapper.*;
import com.morehair.service.admin.GoodsService;
import com.morehair.utils.DateUtil;
import com.morehair.utils.StringOfGoodsUtil;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * Description:
 * Date: 2021/6/5
 * Time: 19:56
 * author: zhang wei
 */

@Service
@Transactional
public class GoodsServiceImpl implements GoodsService {

    @Autowired
    GoodsMapper goodsMapper;

    @Autowired
    BrandMapper brandMapper;

    @Autowired
    CategoryMapper categoryMapper;

    @Autowired
    AttributeOfGoodsMapper attributeOfGoodsMapper;

    @Autowired
    ProductOfGoodsMapper productOfGoodsMapper;

    @Autowired
    SpecificationOfGoodsMapper specificationOfGoodsMapper;

    // public static List<String> stringToList(String preStr) {
    //     List<String> list = new ArrayList<>();
    //     if (preStr.length() > 4) {
    //         String[] strArr = preStr.substring(1, preStr.length() - 1).split(",");
    //         // 数组转化为List
    //         for (String str : strArr) {
    //             list.add(str.substring(1, str.length() - 1));
    //         }
    //     }
    //     return list;
    // }

    @Override
    public GoodsDataVo getGoodsList(Integer page, Integer limit, Integer goodsSn, String name, String sort, String order) {
        PageHelper.startPage(page, limit);
        GoodsExample goodsExample = new GoodsExample();
        goodsExample.setOrderByClause(sort + " " + order);
        GoodsExample.Criteria criteria = goodsExample.createCriteria();
        criteria.andDeletedEqualTo(false);
        if (name != null && !"".equals(name)) {
            criteria.andNameLike("%" + name + "%");
        }
        if (goodsSn != null && !"".equals(goodsSn)) {
            criteria.andGoodsSnLike("%" + goodsSn + "%");
        }

        // List<Goods> goods = goodsMapper.selectByExample(goodsExample);
        List<Goods> goods = goodsMapper.selectByExampleWithBLOBs(goodsExample);
        List<GoodsVo> goodsVos = new ArrayList<>();
        for (Goods good : goods) {
            GoodsVo goodsVo = new GoodsVo(good.getId(),
                    good.getGoodsSn(),
                    good.getName(),
                    good.getCategoryId(),
                    good.getBrandId(),
                    null,
                    good.getKeywords(),
                    good.getBrief(),
                    good.getIsOnSale(),
                    good.getSortOrder(),
                    good.getPicUrl(),
                    good.getShareUrl(),
                    good.getIsNew(),
                    good.getIsHot(),
                    good.getUnit(),
                    good.getCounterPrice(),
                    good.getRetailPrice(),
                    good.getAddTime(),
                    good.getUpdateTime(),
                    good.getDeleted(),
                    good.getDetail());
            List<String> strings = StringOfGoodsUtil.stringToList(good.getGallery());
            goodsVo.setGallery(strings);
            goodsVos.add(goodsVo);
        }
        PageInfo<Goods> pageInfo = new PageInfo<>(goods);
        long total = pageInfo.getTotal();

        GoodsDataVo goodsDataVO = new GoodsDataVo();
        goodsDataVO.setTotal((int) total);
        goodsDataVO.setItems(goodsVos);
        return goodsDataVO;
    }

    @Override
    public CatAndBrandVo selectCatAndBrand() {
        CategoryExample categoryExample = new CategoryExample();
        BrandExample brandExample = new BrandExample();
        // CategoryExample.Criteria categoryCriteria = categoryExample.createCriteria();
        // BrandExample.Criteria brandCriteria = brandExample.createCriteria();
        //查询表Category所有数据
        //查询表Brand所有数据
        List<CategoryOfGoodsVo> categoryOfGoodsVos = new ArrayList<>();
        List<BrandOfGoodsVo> brandOfGoodsVos = new ArrayList<>();

        List<Category> categories = categoryMapper.selectByExample(categoryExample);
        for (Category category : categories) {
            if (category.getPid() == 0) {

                CategoryOfGoodsVo categoryOfGoodsVo = new CategoryOfGoodsVo();
                Integer id = category.getId();
                categoryOfGoodsVo.setValue(id);
                categoryOfGoodsVo.setLabel(category.getName());
                List<Category> categoriesOfChildren = categoryMapper.selectByExample(categoryExample);
                List<CategoryOfGoodsVo.Children> childrenList = new ArrayList<>();
                for (Category categoriesOfChild : categoriesOfChildren) {
                    if (categoriesOfChild.getPid().equals(id)) {
                        CategoryOfGoodsVo.Children children = new CategoryOfGoodsVo.Children();
                        children.setValue(categoriesOfChild.getId());
                        children.setLabel(categoriesOfChild.getName());
                        childrenList.add(children);
                    }
                }
                categoryOfGoodsVo.setChildren(childrenList);
                categoryOfGoodsVos.add(categoryOfGoodsVo);
            }
        }
        List<Brand> brands = brandMapper.selectByExample(brandExample);
        for (Brand brand : brands) {
            BrandOfGoodsVo brandOfGoodsVo = new BrandOfGoodsVo();
            brandOfGoodsVo.setValue(brand.getId());
            brandOfGoodsVo.setLabel(brand.getName());
            brandOfGoodsVos.add(brandOfGoodsVo);
        }
        CatAndBrandVo catAndBrandVo = new CatAndBrandVo();
        catAndBrandVo.setBrandList(brandOfGoodsVos);
        catAndBrandVo.setCategoryList(categoryOfGoodsVos);
        return catAndBrandVo;
    }

    @Override
    public boolean deleteGoodsById(GoodsBo goodsBo) {
        // Goods goods = new Goods();
        int i = goodsMapper.fakeDeleteById(goodsBo.getId(), DateUtil.nowTime());
        if (i == 1) return true;
        return false;
    }


    @Override
    public boolean createGoods(CreateGoodsBo createGoodsBo) {
        List<CreateGoodsBo.AttributeBean> attributesBeanList = createGoodsBo.getAttributes();
        List<CreateGoodsBo.ProductsBean> productsBeanList = createGoodsBo.getProducts();
        List<CreateGoodsBo.SpecificationsBean> specificationsBeanList = createGoodsBo.getSpecifications();
        CreateGoodsBo.GoodsBean goodsBean = createGoodsBo.getGoods();

        // 新增goods表项
        Goods goods = new Goods();
        goods.setGoodsSn(goodsBean.getGoodsSn());
        goods.setName(goodsBean.getName());
        goods.setCategoryId(goodsBean.getCategoryId());
        goods.setBrandId(goodsBean.getBrandId());
        goods.setGallery(goodsBean.getGallery().toString());
        goods.setKeywords(goodsBean.getKeywords());
        goods.setBrief(goodsBean.getBrief());
        goods.setIsOnSale(goodsBean.getIsOnSale());
        goods.setPicUrl(goodsBean.getPicUrl());
        goods.setIsNew(goodsBean.getIsNew());
        goods.setIsHot(goodsBean.getIsHot());
        goods.setUnit(goodsBean.getUnit());
        goods.setCounterPrice(new BigDecimal(String.valueOf(goodsBean.getCounterPrice())));
        goods.setRetailPrice(new BigDecimal(String.valueOf(goodsBean.getRetailPrice())));
        goods.setAddTime(DateUtil.nowTime());
        goods.setUpdateTime(DateUtil.nowTime());
        goods.setDeleted(false);
        goods.setDetail(goodsBean.getDetail());
        goodsMapper.insertSelective(goods);

        /**
         * 拿到商品
         */
        String goodsSn = goodsBean.getGoodsSn();
        Integer categoryId = goodsBean.getCategoryId();
        String name = goodsBean.getName();

        int goodsId = goodsMapper.getTheId(name, goodsSn, categoryId);

        /**
         * 新增attribute表项
         */
        for (CreateGoodsBo.AttributeBean attributeBean : attributesBeanList) {
            AttributeOfGoods attributeOfGoods = new AttributeOfGoods();
            attributeOfGoods.setValue(attributeBean.getValue());
            attributeOfGoods.setGoodsId(goodsId);
            attributeOfGoods.setAttribute(attributeBean.getAttribute());
            attributeOfGoods.setAddTime(DateUtil.nowTime());
            attributeOfGoods.setUpdateTime(DateUtil.nowTime());
            attributeOfGoods.setDeleted(false);
            attributeOfGoodsMapper.insertSelective(attributeOfGoods);
        }

        /**
         * 新增product表项
         */
        for (CreateGoodsBo.ProductsBean productsBean : productsBeanList) {
            ProductOfGoods productOfGoods = new ProductOfGoods();
            // productOfGoods.setId(productsBean.getId());
            productOfGoods.setPrice(new BigDecimal(productsBean.getPrice()));
            productOfGoods.setNumber(productsBean.getNumber());
            productOfGoods.setUrl(productsBean.getUrl());

            List<String> specifications = productsBean.getSpecifications();


            List<String> stringArrayList = new ArrayList<>();
            for (String specification : specifications) {
                StringBuffer stringBuffer = new StringBuffer();
                stringBuffer.append("\"").append(specification).append("\"");
                stringArrayList.add(stringBuffer.toString());
            }

            // StringBuffer buffer = new StringBuffer();
            // String toString = stringArrayList.toString();
            // buffer.append("[").append(toString).append("]");
            // productOfGoods.setSpecifications(buffer.toString());

            productOfGoods.setSpecifications(stringArrayList.toString());

            productOfGoods.setGoodsId(goodsId);
            productOfGoods.setAddTime(DateUtil.nowTime());
            productOfGoods.setUpdateTime(DateUtil.nowTime());
            productOfGoods.setDeleted(false);
            productOfGoodsMapper.insertSelective(productOfGoods);
        }

        /**
         * 新增specification表项
         */
        for (CreateGoodsBo.SpecificationsBean specificationsBean : specificationsBeanList) {
            SpecificationOfGoods specificationOfGoods = new SpecificationOfGoods();
            specificationOfGoods.setSpecification(specificationsBean.getSpecification());
            // specificationOfGoods.setValue(Integer.toString(specificationsBean.getValue()));
            specificationOfGoods.setValue(specificationsBean.getValue());
            specificationOfGoods.setPicUrl(specificationsBean.getPicUrl());
            specificationOfGoods.setGoodsId(goodsId);
            specificationOfGoods.setAddTime(DateUtil.nowTime());
            specificationOfGoods.setUpdateTime(DateUtil.nowTime());
            specificationOfGoods.setDeleted(false);
            specificationOfGoodsMapper.insertSelective(specificationOfGoods);
        }
        return true;
    }


    @Override
    public DetailOfGoodsVo detailOfGoods(Integer id) {
        //id ==GoodsId
        Goods goods = goodsMapper.selectByPrimaryKey(id);
        GoodsVo goodsVo = new GoodsVo();

        /**
         * ------------------------GoodsVo------------------------------------------------
         */
        goodsVo.setId(id);
        goodsVo.setGoodsSn(goods.getGoodsSn());
        goodsVo.setName(goods.getName());
        goodsVo.setCategoryId(goods.getCategoryId());
        goodsVo.setBrandId(goods.getBrandId());

        // String gallery = goods.getGallery();
        // goodsVo.setGallery(StringOfGoodsUtil.stringToList(gallery));

        String galleryStr = goods.getGallery();
        List<String> galleryList = StringOfGoodsUtil.stringToList(galleryStr);
        goodsVo.setGallery(galleryList);

        goodsVo.setKeywords(goods.getKeywords());
        goodsVo.setBrief(goods.getBrief());
        goodsVo.setIsOnSale(goods.getIsOnSale());
        goodsVo.setSortOrder(goods.getSortOrder());
        goodsVo.setPicUrl(goods.getPicUrl());
        goodsVo.setShareUrl(goods.getShareUrl());
        goodsVo.setIsNew(goods.getIsNew());
        goodsVo.setIsHot(goods.getIsHot());
        goodsVo.setUnit(goods.getUnit());
        goodsVo.setCounterPrice(goods.getCounterPrice());
        goodsVo.setRetailPrice(goods.getRetailPrice());
        goodsVo.setAddTime(goods.getAddTime());
        goodsVo.setUpdateTime(goods.getUpdateTime());
        goodsVo.setDeleted(goods.getDeleted());
        goodsVo.setDetail(goods.getDetail());


        /**
         * ------------------------categoryIds------------------------------------------------
         */
        Integer sid = goods.getCategoryId();
        Category category = categoryMapper.selectByPrimaryKey(sid);
        Integer pid = category.getPid();
        List<Long> categoryIds = new ArrayList<>();
        categoryIds.add((long) pid);
        categoryIds.add((long) sid);


        /**
         * ------------------------attributes------------------------------------------------
         */

        List<AttributeOfGoods> attributes = attributeOfGoodsMapper.selectByGoodsId(id);


        /**
         * ------------------------specifications------------------------------------------------
         */

        List<SpecificationOfGoods> specifications = specificationOfGoodsMapper.selectByGoodsId(id);

        /**
         * ------------------------products------------------------------------------------
         */
        List<ProductOfGoods> productOfGoodsList = productOfGoodsMapper.selectByGoodsId(id);
        List<DetailOfGoodsVo.Products> products = new ArrayList<>();
        for (ProductOfGoods productOfGoods : productOfGoodsList) {
            DetailOfGoodsVo.Products product = new DetailOfGoodsVo.Products();
            product.setId(productOfGoods.getId());
            product.setGoodsId(id);

            String getSpecifications = productOfGoods.getSpecifications();

            List<String> strings = StringOfGoodsUtil.stringToList(getSpecifications);

            System.out.println("*********************");
            System.out.println(getSpecifications);
            System.out.println("*********************");
            System.out.println("*********************");
            System.out.println(strings);
            System.out.println("*********************");
            product.setSpecifications(strings);

            product.setPrice(productOfGoods.getPrice());
            product.setNumber(productOfGoods.getNumber());
            product.setUrl(productOfGoods.getUrl());
            product.setAddTime(productOfGoods.getAddTime());
            product.setUpdateTime(productOfGoods.getUpdateTime());
            product.setDeleted(productOfGoods.getDeleted());
            products.add(product);
        }



















        DetailOfGoodsVo detailOfGoodsVo = new DetailOfGoodsVo();
        detailOfGoodsVo.setGoods(goodsVo);
        detailOfGoodsVo.setCategoryIds(categoryIds);
        detailOfGoodsVo.setAttributes(attributes);
        detailOfGoodsVo.setSpecifications(specifications);
        detailOfGoodsVo.setProducts(products);

        return detailOfGoodsVo;
    }

    @Override
    public void updateGoods(UpdateGoodsBo updateGoodsBo) {

        //UpdateGoods
        GoodsBo goodsBo = updateGoodsBo.getGoods();
        Goods goods = new Goods();
        goods.setId(goodsBo.getId());
        goods.setGoodsSn(goodsBo.getGoodsSn());
        goods.setName(goodsBo.getName());
        goods.setCategoryId(goodsBo.getCategoryId());
        goods.setBrandId(goodsBo.getBrandId());
        goods.setGallery(goodsBo.getGallery().toString());
        goods.setKeywords(goodsBo.getKeywords());
        goods.setBrief(goodsBo.getBrief());
        goods.setIsOnSale(goodsBo.getIsOnSale());
        goods.setSortOrder(goodsBo.getSortOrder());
        goods.setPicUrl(goodsBo.getPicUrl());
        goods.setShareUrl(goodsBo.getShareUrl());
        goods.setIsNew(goodsBo.getIsNew());
        goods.setIsHot(goodsBo.getIsHot());
        goods.setUnit(goodsBo.getUnit());
        goods.setCounterPrice(goodsBo.getCounterPrice());
        goods.setRetailPrice(goodsBo.getRetailPrice());
        goods.setAddTime(goodsBo.getAddTime());
        goods.setUpdateTime(DateUtil.nowTime());
        goods.setDeleted(goodsBo.getDeleted());
        goods.setDetail(goodsBo.getDetail());
        goodsMapper.updateByPrimaryKeySelective(goods);

        //拿到商品ID
        Integer goodsId = goodsBo.getId();


        //UpdateAttribute

        List<AttributeOfGoods> attributes = updateGoodsBo.getAttributes();
        int m = 0;//已有的数量
        int n = 0;//新增的数量
        for (AttributeOfGoods attribute : attributes) {
            Integer id = attribute.getId();
            if (id != null) m++;
            else n++;
        }
        int sizeOfAttribute = attributeOfGoodsMapper.selectByGoodsIdAndNoDeleted(goodsId);
        if (m < sizeOfAttribute) {
            //小于的话有删除
            //先将所有的，deleted为false的全部设置成true
            attributeOfGoodsMapper.updateBeforeDeleteById(goodsId);
            //然后根据每个去修改，并将这些的deleted再改成false
            for (AttributeOfGoods attribute : attributes) {
                AttributeOfGoodsExample attributeOfGoodsExample = new AttributeOfGoodsExample();
                AttributeOfGoodsExample.Criteria criteria = attributeOfGoodsExample.createCriteria();
                if (attribute.getId() != null) {
                    criteria.andIdEqualTo(attribute.getId());
                    AttributeOfGoods attributeOfGoods = new AttributeOfGoods();

                    attributeOfGoods.setId(attribute.getId());
                    attributeOfGoods.setGoodsId(attribute.getGoodsId());
                    attributeOfGoods.setAttribute(attribute.getAttribute());
                    attributeOfGoods.setValue(attribute.getValue());
                    attributeOfGoods.setAddTime(attribute.getAddTime());
                    attributeOfGoods.setUpdateTime(DateUtil.nowTime());
                    attributeOfGoods.setDeleted(false);
                    attributeOfGoodsMapper.updateByExample(attributeOfGoods, attributeOfGoodsExample);
                }
            }
        } else if (m == sizeOfAttribute) {
            //等于的话只进行修改
            for (AttributeOfGoods attribute : attributes) {
                AttributeOfGoodsExample attributeOfGoodsExample = new AttributeOfGoodsExample();
                AttributeOfGoodsExample.Criteria criteria = attributeOfGoodsExample.createCriteria();
                if (attribute.getId() != null) {
                    criteria.andIdEqualTo(attribute.getId());
                    AttributeOfGoods attributeOfGoods = new AttributeOfGoods();
                    attributeOfGoods.setId(attribute.getId());
                    attributeOfGoods.setGoodsId(attribute.getGoodsId());
                    attributeOfGoods.setAttribute(attribute.getAttribute());
                    attributeOfGoods.setValue(attribute.getValue());
                    attributeOfGoods.setAddTime(attribute.getAddTime());
                    attributeOfGoods.setUpdateTime(DateUtil.nowTime());
                    attributeOfGoods.setDeleted(attribute.getDeleted());
                    attributeOfGoodsMapper.updateByExample(attributeOfGoods, attributeOfGoodsExample);
                }
            }
        } else {
            //不可能大于
            System.out.println("能走到这我吃屎");
        }
        if (n > 0) {
            //有新增
            for (AttributeOfGoods attribute : attributes) {
                if (attribute.getId() == null) {
                    AttributeOfGoods attributeOfGoods = new AttributeOfGoods();
                    attributeOfGoods.setGoodsId(goodsId);
                    attributeOfGoods.setAttribute(attribute.getAttribute());
                    attributeOfGoods.setValue(attribute.getValue());
                    attributeOfGoods.setAddTime(DateUtil.nowTime());
                    attributeOfGoods.setUpdateTime(DateUtil.nowTime());
                    attributeOfGoods.setDeleted(false);
                    attributeOfGoodsMapper.insertSelective(attributeOfGoods);
                }
            }
        }


        //UpdateSpecification
        List<SpecificationOfGoods> specifications = updateGoodsBo.getSpecifications();
        int i = 0;//已有的数量
        int j = 0;//新增的数量
        for (SpecificationOfGoods specification : specifications) {
            Integer id = specification.getId();
            if (id != null) i++;
            else j++;
        }
        int sizeOfSpecification = specificationOfGoodsMapper.selectByGoodsIdAndNoDeleted(goodsId);
        if (i < sizeOfSpecification) {
            //小于的话有删除
            //先将所有的，deleted为false的全部设置成true
            specificationOfGoodsMapper.updateBeforeDeleteById(goodsId);
            //然后根据每个去修改，并将这些的deleted再改成false
            for (SpecificationOfGoods specification : specifications) {
                SpecificationOfGoodsExample specificationOfGoodsExample = new SpecificationOfGoodsExample();
                SpecificationOfGoodsExample.Criteria criteria = specificationOfGoodsExample.createCriteria();
                if (specification.getId() != null) {
                    criteria.andIdEqualTo(specification.getId());
                    SpecificationOfGoods specificationOfGoods = new SpecificationOfGoods();

                    specificationOfGoods.setId(specification.getId());
                    specificationOfGoods.setGoodsId(specification.getGoodsId());
                    specificationOfGoods.setSpecification(specification.getSpecification());
                    specificationOfGoods.setValue(specification.getValue());
                    specificationOfGoods.setPicUrl(specification.getPicUrl());
                    specificationOfGoods.setAddTime(specification.getAddTime());
                    specificationOfGoods.setUpdateTime(DateUtil.nowTime());
                    specificationOfGoods.setDeleted(false);
                    specificationOfGoodsMapper.updateByExample(specificationOfGoods, specificationOfGoodsExample);
                }
            }
        } else if (i == sizeOfSpecification) {
            //等于的话只进行修改
            for (SpecificationOfGoods specification : specifications) {
                SpecificationOfGoodsExample specificationOfGoodsExample = new SpecificationOfGoodsExample();
                SpecificationOfGoodsExample.Criteria criteria = specificationOfGoodsExample.createCriteria();
                if (specification.getId() != null) {
                    criteria.andIdEqualTo(specification.getId());
                    SpecificationOfGoods specificationOfGoods = new SpecificationOfGoods();
                    specificationOfGoods.setId(specification.getId());
                    specificationOfGoods.setGoodsId(specification.getGoodsId());
                    specificationOfGoods.setSpecification(specification.getSpecification());
                    specificationOfGoods.setValue(specification.getValue());
                    specificationOfGoods.setPicUrl(specification.getPicUrl());
                    specificationOfGoods.setAddTime(specification.getAddTime());
                    specificationOfGoods.setUpdateTime(DateUtil.nowTime());
                    specificationOfGoods.setDeleted(specification.getDeleted());
                    specificationOfGoodsMapper.updateByExample(specificationOfGoods, specificationOfGoodsExample);
                }
            }
        } else {
            //不可能大于
            System.out.println("能走到这我吃屎");
        }
        if (j > 0) {
            //有新增
            for (SpecificationOfGoods specification : specifications) {
                if (specification.getId() == null) {
                    SpecificationOfGoods specificationOfGoods = new SpecificationOfGoods();
                    specificationOfGoods.setSpecification(specification.getSpecification());
                    specificationOfGoods.setValue(specification.getValue());
                    specificationOfGoods.setPicUrl(specification.getPicUrl());
                    specificationOfGoods.setGoodsId(goodsId);
                    specificationOfGoods.setAddTime(DateUtil.nowTime());
                    specificationOfGoods.setUpdateTime(DateUtil.nowTime());
                    specificationOfGoods.setDeleted(false);
                    specificationOfGoodsMapper.insertSelective(specificationOfGoods);
                }
            }
        }

        //UpdateProducts
        //先删除再添加

        productOfGoodsMapper.deleteByGoodsId(goodsId);

        List<UpdateGoodsBo.Product> products = updateGoodsBo.getProducts();

        for (UpdateGoodsBo.Product productsBean : products) {
            ProductOfGoods productOfGoods = new ProductOfGoods();
            // productOfGoods.setId(productsBean.getId());
            productOfGoods.setPrice(new BigDecimal(String.valueOf(productsBean.getPrice())));
            productOfGoods.setNumber(productsBean.getNumber());
            productOfGoods.setUrl(productsBean.getUrl());

            List<String> specific = productsBean.getSpecifications();
            List<String> stringArrayList = new ArrayList<>();
            for (String specification : specific) {
                StringBuffer stringBuffer = new StringBuffer();
                stringBuffer.append("\"").append(specification).append("\"");
                stringArrayList.add(stringBuffer.toString());
            }

            productOfGoods.setSpecifications(stringArrayList.toString());

            productOfGoods.setGoodsId(goodsId);
            productOfGoods.setAddTime(DateUtil.nowTime());
            productOfGoods.setUpdateTime(DateUtil.nowTime());
            productOfGoods.setDeleted(false);
            productOfGoodsMapper.insertSelective(productOfGoods);

        }


    }
}

